import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/Table';
import { airportList } from '@apps/ant-bus/src/views/business/airport/data/api';
import { employeeList } from '@apps/ant-bus/src/views/business/employeeManage/employee/data/api';
import { vipcardList } from '@apps/ant-bus/src/views/business/goods/vipcard/data/api';
import { render } from '@apps/antd-admin/src/hooks/render/renderUtils';
import { RenderType } from '@pkg/setting';

export const columns: BasicColumn[] = [
  {
    title: '会员姓名',
    dataIndex: 'userName',
    width: 120,
  },
  {
    title: '手机号',
    dataIndex: 'mobile',
    width: 120,
  },
  {
    title: '会员卡号',
    dataIndex: 'vipCardNo',
    width: 150,
  },
  {
    title: '升降卡日期',
    dataIndex: 'createTime',
    width: 150,
  },
  {
    title: '原支付金额',
    dataIndex: 'oldPayAmount',
    width: 120,
  },
  {
    title: '实际支付/退款金额',
    dataIndex: 'realPayAmount',
    width: 150,
  },
  {
    title: '升降卡金额',
    dataIndex: 'newPayAmount',
    width: 120,
  },
  /*{
    title: '会员承担金额',
    dataIndex: 'vipBearAmount',
    width: 120,
  },*/
  {
    title: '原开卡日期',
    dataIndex: 'buyDate',
    width: 120,
  },
  {
    title: '升降卡所属地区',
    dataIndex: 'newAirportName',
    width: 150,
  },
  {
    title: '升降卡卡种',
    dataIndex: 'newGoodsName',
    width: 150,
  },
  {
    title: '升降卡所属销售',
    dataIndex: 'newEmployeeName',
    width: 150,
  },
  {
    title: '原销售',
    dataIndex: 'oldEmployeeName',
    width: 150,
  },
  {
    title: '原地区',
    dataIndex: 'oldAirportName',
    width: 150,
  },
  {
    title: '原卡种',
    dataIndex: 'oldGoodsName',
    width: 150,
  },
  {
    title: '退款类型',
    dataIndex: 'refundSourceType',
    width: 120,
    dictData: [
      { label: '无', value: 0, color: '#a6a9a6' },
      { label: '现办现退', value: 1, color: '#ee0303' },
      { label: '普通退卡', value: 2, color: '#032aee' },
    ],
    renderType: RenderType.DICT,
  },
  {
    title: '备注',
    dataIndex: 'remark',
    width: 150,
    customRender: render.renderTxt,
  },
  {
    title: '操作人',
    dataIndex: 'optUserName',
    width: 150,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'startDate',
    label: '开始日期',
    component: 'DatePicker',
    colProps: { span: 5 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
  {
    field: 'endDate',
    label: '结束日期',
    component: 'DatePicker',
    colProps: { span: 5 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
  {
    field: 'vipCardNo',
    label: '会员卡号',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'userName',
    label: '会员姓名',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'mobile',
    label: '手机号',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'oldGoodsIdArray',
    label: '原卡种',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: {
      api: vipcardList,
      params: { handlerName: 'busVipCardListHandler' },
      labelField: 'goodsName',
      valueField: 'goodsId',
      immediate: true,
      showSearch: true,
      mode: 'multiple',
    },
  },
  {
    field: 'newAirportIdArray',
    label: '升卡机场',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: {
      api: airportList,
      labelField: 'airportName',
      valueField: 'airportId',
      immediate: true,
      showSearch: true,
      mode: 'multiple',
    },
  },
  {
    label: '升卡销售',
    field: 'newEmployeeId',
    component: 'ApiSelect',
    required: false,
    componentProps: ({ formModel }) => {
      return {
        api: employeeList,
        params: { handlerName: 'busEmployeeListHandler', airportId: formModel.newAirportId },
        labelField: 'employeeName',
        valueField: 'employeeId',
        immediate: true,
        showSearch: true,
      };
    },
  },
];

export const remarkFormSchema: FormSchema[] = [
  {
    label: '升降级记录Id',
    field: 'upgradeRecordId',
    component: 'Input',
    show: false,
    required: true,
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
    required: false,
    componentProps: {
      autoSize: { minRows: 2, maxRows: 30 },
      maxLength: 200,
    },
  },
];
